/*** Miscelaneous Utility Functions ***/
#ifndef _VALUE_H_
#define _VALUE_H_

#ifdef __cplusplus
extern "C" {
#endif /** cplusplus **/

#include "libutil.h"

typedef struct
{
  char *word; /* The word or non-word character string */
  int type;            /* 0 for word and 1 for non-word */
  unsigned int id;     /* A unique integer identifier for each distinct word */
  int count;
} value_t;

/* Compare a value_t->word to a string */
int scmp (const void *sp1, const void *sp2);
/* Compare a value_t->word to a value_t->word */
int svcmp (const void *sp1, const void *sp2);
/* Compare a value_t->id to a id */
int idcmp (const void *sp1, const void *sp2);
/* Compare a value_t->count to a value_t->count */
int cntcmp (const void *sp1, const void *sp2);

/* Delete a value type */
void delete_value (void *data);

/* Sort an array of value types based on a compare function */
void insertion_sort (value_t** A, int n, 
                     int (*cmp_fptr)(const void*,const void*));

#ifdef __cplusplus
}
#endif /** cplusplus **/

#endif /** _LIBUTIL_H_ **/

